# 配置信息 Start #
# 读取配置文件的内容

# 获取当前操作系统的架构数组,windows 期望结果是"x86_64","x86"
jq -r '.archs.windows | keys.[]' $g_configFile
archsString=$(jq -r '.archs.windows | keys.[]' $g_configFile)
archs2=($archsString)
echo -e "$archsString"
# archBuildFlagsString=$(jq '.archs.windows.[]' $g_configFile)
# echo -e "$archBuildFlagsString"
# archBuildFlags=($archBuildFlagsString)
# echo ${archBuildFlags[1]}
# 配置信息 End #

export g_platform="windows"
export g_inputPlatformDir="${g_inputRootDir}/${g_platform}"
export g_scriptPlatformDir="${SCRITP_ROOT_DIR}/${g_platform}"
export g_buildPlatformDir="${g_buildConfigureDir}/${g_platform}"
export g_outputPlatformDir="${g_outputConfigureDir}/${g_platform}"

# audiotoolbox的使用在11之后比较好.
export g_minSdkVersion="11.0"



declare -i length=${#archs2[@]}
arch=${archs2[1]}
echo $arch
# echo "lengh222 is: $length"
# for((i = 0; i < 2; i++)); do
archBuildFlag=`eval "jq -r '.archs.windows.$arch' $g_configFile"`
echo arch:${arch},archBuildFlag:${archBuildFlag}
if [[ "${archBuildFlag}" == "$FLAG_YES" ]]; then
    echo "executing ${g_projectDir}/02-script/${g_platform}/${arch}/${g_platform}-${arch}-manager.sh"
    . ${g_projectDir}/02-script/${g_platform}/${arch}/${g_platform}-${arch}-manager.sh 
else
    echo "skip"
fi
# done


# function mergeThinToFat() {
#     echo "Merge,begin"

#     fatDir=${g_outputPlatformDir}/fat
#     if [[ ! -e ${fatDir} ]]; then
#         mkdir -p ${fatDir}
#     fi
#     mkdir -p $fatDir/lib
#     # ls的结果是空格分开的,可以用for in迭代.
#     archArray=`ls $g_outputPlatformDir | grep -v "fat"`
#     # 分割字符串并设置位置参数,但是好像不加--也可以.
#     set -- $archArray
    
#     # 复制头文件到fatDir
#     cp -rf $g_outputPlatformDir/$1/lame-3.100/include $fatDir

#     cd $g_outputPlatformDir/$1/lame-3.100/lib
#     for libName in *.a; do
#         # 针对当前目录的每一个.a文件,从thinDir中,寻找同名的,进行合并
#         # 放到变量之中后,变成一个字符串了,而不是数组.
#         thinLibPath=$(find $g_outputPlatformDir -name $libName)
#         echo "thinLibPath is: $thinLibPath"
#         lipo -create $(find $g_outputPlatformDir -name $libName) -output $fatDir/lib/$libName
#     done

#     echo "Merge,compete"
# }

# isMerge=$FLAG_NO

# #合并Thin->Fat,.执行合并操作.
# if [[ $isMerge == $FLAG_YES ]]; then
#     items=`ls ${g_outputPlatformDir}`
#     # 去掉fat文件夹的文件夹的个数.
#     itemCount=`ls -l ${g_outputPlatformDir} |grep "^d" | grep -v "fat" |wc -l`
#     if [[ $itemCount -ge "2" ]]; then
#         mergeThinToFat
#     fi
# fi
